import Constant from './Constant'
export function handleHtml(content) {
    const HOST = Constant.HOST;
    let html = content;
    let arr = content.split("<img");
    if (arr instanceof Array && arr.length > 0) {
        html = arr[0];
        for (let i = 1; i < arr.length; i++) {
            let ret = arr[i];
            const ind = arr[i].indexOf('src=\"');

            if (ind != -1) {
                let mid = HOST;
                const S1 = arr[i].substring(0, ind + 5)
                const S2 = arr[i].substring(ind + 5)
                // if (S2.startsWith('/resource/')) {
                //     mid = HOST;
                // }
                ret = S1 + mid + S2;
            }
            html = html + "<img style='width:100%'" + ret
        }
    }
    return html
}

export function handleBannerImg(urls) {
    let arr = urls.split(';');
    const rule = "NoticeTitle";
    let topicImg = arr[0];
    for (let i = 0; i < arr.length; i++) {
        if (arr[i].search(/NoticeTitle/i) != -1) {
            topicImg = arr[i];
            break;
        }
    }
    return topicImg
}